package com.hiyee.customer.controller;

import com.hiyee.api.controller.BaseController;
import com.hiyee.api.controller.customer.CustomerControllerApi;
import com.hiyee.customer.service.CustomerService;
import com.hiyee.pojo.auth.LoginCustomer;
import com.hiyee.pojo.repo.CustomerInfoRepo;
import com.hiyee.response.ResponseJsonResult;
import com.hiyee.response.ResponseStatusEnum;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

@RestController
public class CustomerController extends BaseController implements CustomerControllerApi {

    @Autowired
    private CustomerService customerService;

    @Override
    public ResponseJsonResult getInfo(Long customerId) {
        CustomerInfoRepo customerInfo = customerService.getInfo(customerId);
        if(customerInfo == null) {
            return ResponseJsonResult.error(ResponseStatusEnum.CUSTOMER_NOT_FOUND);
        }
        return ResponseJsonResult.success(customerInfo);
    }

    @Override
    public ResponseJsonResult getAccount(LoginCustomer loginCustomer) {
        Map<String, Object> data = new HashMap<>();
        data.put("balance", 1000);
        data.put("coupon", 1);
        data.put("points", 1);
        return ResponseJsonResult.success(data);
    }

    @Override
    public ResponseJsonResult getOrderStat(LoginCustomer loginCustomer) {
        Map<String, Object> data = new HashMap<>();
        data.put("afterSales_num", 1000);
        data.put("wait_comment", 1);
        data.put("wait_delivery_num", 1);
        data.put("wait_pay_num", 1);
        data.put("wait_receive_num", 1);
        return ResponseJsonResult.success(data);
    }
}
